const baseController = require("./baseController");
const userModel = require("../../model/userModel");
const encAndDec = require("../../untis/encAndDec");

let mysql = require("../../model/base");

class userController extends baseController {
    async login() {
        return this.display("login.html");
    }
    //前台用户注册页面
    async userReg() {
        return this.display("userReg.html");
    }
    //后端逻辑用户注册
    async handleReg() {
        let name = this.req.post['username'];
        let password = encAndDec.md5(this.req.post['password']);
        // console.log(this.req.    post); //获取用户名和密码数据  //加解密 crypto模板
        return this.display("userReg.html");
        //完善-------->写入到 数据库
    }

    async userList() {
        let user = new userModel();
        try {
            let userList = await user.select();
            return JSON.stringify(userList);//就是把对象转成json格式
        } catch (err) {
            console.log(err);
        }
    }
}
module.exports = userController;